Skip to content

Fix relative index URLs - #230

Merged
ryanking13 merged 2 commits into
pyodide:mainfrom
juntyr:patch-1
Jul 1, 2025
Merged

Fix relative index URLs#230
ryanking13 merged 2 commits into
pyodide:mainfrom
juntyr:patch-1

Conversation

@juntyr

@juntyr juntyr commented Apr 6, 2025

Copy link
Copy Markdown
Contributor

Fixes #229

@agriyakhetarpal agriyakhetarpal left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @juntyr! Would it be possible for you to add a test?

@ryanking13 ryanking13 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, sorry for the late review.

Anaconda package index requires the previous behavior.

The index URL is:

and the relative URL in the response is

  • /pyodide/simple/zstandard/0.22.0/zstandard-0.22.0-cp312-cp312-pyodide_2024_0_wasm32.whl

So we needed to strip out the path part of the index URL (/pyodide/simple/) and append the relative URL.

Maybe there is some other package index which have different behavior? Could you please tell us which package index you are having an issue?

@juntyr

juntyr commented Jun 30, 2025

Copy link
Copy Markdown
Contributor Author

This is for the index I host together with my custom Pyodide deployment. The index lists all packages that were built just for Pyodide.

Each version of the lab has its own index, so e.g. there is

When navigating the links in the web browser, everything works, so the relative links seem to be correctly set up. From my understanding, the simple HTML index supports relative URLs with the same meaning as when using a web browser.

I could of course switch to absolute URLs but don't really want to bake in the full URL since it would directly tie everything to where the lab is currently being hosted.

@ryanking13

ryanking13 commented Jul 1, 2025

Copy link
Copy Markdown
Member

I see. Thanks.

So, if the relative URL starts with / (anaconda case), then it should be concatenated with the base URL, otherwise if, it should be concatenated to the full URL.

It looks like urllib.parse.urljoin handles this correctly. Let me see if I can fix the logic with it.

>>> urljoin("https://my.index.com/simple/hello/", "../mywhl.whl")
'https://my.index.com/simple/mywhl.whl'
>>> urljoin("https://my.index.com/simple/hello/", "/mywhl.whl")
'https://my.index.com/mywhl.whl'

@ryanking13

Copy link
Copy Markdown
Member

Oh, okay, looks like it is already fixed in #174. I think we can merge this then. Thanks!

@ryanking13
ryanking13 merged commit 26fae70 into pyodide:main Jul 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Simple HTML repository relative URLs are broken

3 participants